<?=modules::run('home/top');?>

<body>
<?php
	include_once('function/func.php');
	$user=$this->session->userdata('ProfileInfo');
	if(!$user){
		header('Location: '.PATH_URL);
	}
?>
<div id="wrapper">
	<header>
		<?=modules::run('home/head');?>
	</header>
	
	<nav id="nav">
		<?=modules::run('home/menu')?>
	</nav>
	
	<div class="content">
		<h1>Thông tin đơn hàng</h1>
        <input type="hidden" value="<?php ($this->session->userdata('start'))? print $this->session->userdata('start') : print 0 ?>" id="start" />
		<input type="hidden" value="10" id="per_page" />
		<input type="hidden" value="<?=$user['id']?>" id="idProfile" />
        
        <?php if($result){?>
        <div id="page" style="margin-top: 20px;float: left;display: inline">
            <table cellpadding="0" cellspacing="0" border="0">
                <tr>
                    <th width="135px">Số hóa đơn</th>
                    <th width="340px">Ngày</th>
                    <th width="150px">Giá</th>
                    <th width="150px">Trạng thái</th>              
                    <th width="100px">Xem đơn hàng</th>
                </tr>
				<?php
					foreach($result as $r){
						if($r->status==0){
							$status= 'Đang chờ duyệt';
						}else{
							$status= 'Đã duyệt';
						}
						$priceTmp=$this->cart->getCartDetail($r->id);
						$price='';
						foreach($priceTmp as $row){
							$price +=$row->qty*$row->price;
						}
				?>
                <tr>
                    <td align="center"><?=$r->maHD?></td>
                    <td><?=date('d-m-Y H:i:s',strtotime($r->created))?></td>
                    <td align="center"><?=number_format($price,0,',','.');?> vnđ</td>
                    <td align="center"><?=$status?></td>
                    <td align="center"><a href="<?=PATH_URL.'chi-tiet-don-hang/'.$r->id?>">Xem</a></td>
                </tr>
                <?php }?>
            </table>
            <div class="pagination" style="text-align: right;"><?=$this->adminpagination->create_links();?></div>
        </div>   
        <?php }else{?>
        	<p style="float: left;display: inline;padding-top: 20px;">Bạn chưa có đơn hàng nào hết !!!</p>
        <?php }?>    
	</div><!--end content-->
	
	<footer>
		<?=modules::run('home/footer');?>
	</footer>
</div><!--end wrapper-->
</body>
</html>
